<template>  
    <div :class="['todo-item', todo.completed ? 'completed' :'']">
        <input 
            type="checkbox"
            class="toggle"
            v-model= "todo.completed"
        >
        <label>{{ todo.content }}</label>
        <button class="destroy" @click= "deleteTodo">X</button>
    </div>
</template>
<script>
export default {
    props: {
        todo:{
            type: Object,
            required: true
        }
    },
    methods: {
        deleteTodo(){
            this.$emit('deleteTodo',this.todo.id);
        },
    }
}
</script>
<style lang="scss" scoped>
    .todo-item {
        width: 80%;
        background-color: #fff;
        padding: 10px 50px 20px;
        font-size: 30px;
        display: flex;
        justify-content: start;
    }
    .todo-item input[type="checkbox"] {
        width: 30px;
        height: 30px;
        background-color: none;
        border: 1px solid #c9c9c9;
        outline: none;
    }
    .todo-item.completed label{
        text-decoration: line-through;
        color: #c9c9c9;
    }
    .todo-item label{
        flex-grow:1;
        color: #09a5eb;
        line-height: 1.2;
        text-indent: 1em;
    }
    .todo-item button {
        width: 30px;
        height: 30px;
    }
</style>

